/*
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#if !defined(AGEMOTIONSETUP_H__)
#define AGEMOTIONSETUP_H__

#include "../client/Util.h"

#include "ResourceLoader.h" // [+] InfinitySky. PNG Support from Apex 1.3.8.

#include "ImageDataObject.h"

class CGDIImage;

// CAGEmotion

class CAGEmotion
{
	public:
		typedef CAGEmotion* Ptr;
		typedef list<Ptr> List;
		typedef List::const_iterator Iter;
		
		CAGEmotion();
		~CAGEmotion();
		
		bool Create(const tstring& strEmotionText, const string& strEmotionBmpPath, const string& strEmotionGifPath);
		
		const tstring& getEmotionText() const
		{
			return m_EmotionText;
		}
		HBITMAP getEmotionBmp() const
		{
			return m_EmotionBmp;
		}
		HBITMAP getEmotionBmp(const COLORREF &clrBkColor);
		const string& getEmotionBmpPath() const
		{
			return m_EmotionBmpPath;
		}
		const string& getEmotionGifPath() const
		{
			return m_EmotionGifPath;
		}
		long  getImagePos() const
		{
			return m_ImagePos;
		}
		void setImagePos(long ImagePos)
		{
			m_ImagePos = ImagePos;
		}
		
		bool getDimensions(int *pW, int *pH)
		{
			bool bRet = false;
			if (m_pImagesList && m_ImagePos >= 0)
			{
				IMAGEINFO ii;
				if (m_pImagesList->GetImageInfo(getImagePos(), &ii))
				{
					if (pW)
						*pW = ii.rcImage.right - ii.rcImage.left;
					if (pH)
						*pH = ii.rcImage.bottom - ii.rcImage.top;
						
					bRet = true;
				}
			}
			return bRet;
		}
		static void setImageList(CImageList* pImagesList)
		{
			m_pImagesList = pImagesList;
		}
		
		CGDIImage *getAnimatedImage(HWND hCallbackWnd, DWORD dwCallbackMsg);
		
		IOleObject *GetImageObject(bool bAnimated, IOleClientSite *pOleClientSite, IStorage *pStorage, HWND hCallbackWnd, DWORD dwCallbackMsg, COLORREF BkColor);
		
	protected:
		tstring     m_EmotionText;
		string      m_EmotionBmpPath;
		string      m_EmotionGifPath;
		HBITMAP     m_EmotionBmp;
		long        m_ImagePos;
		static CImageList*  m_pImagesList;
		
		CImageDataObject m_BmpImageObject;
		CGDIImage *m_pGifImage;
		
		bool m_bMaySupportAnimation;
};

// CAGEmotionSetup

class CAGEmotionSetup
{
	public:
		CAGEmotionSetup() : useEmoticons(false) { }
		virtual ~CAGEmotionSetup();
		
		bool LoadEmotion(const string& p_file_name);
		bool InitImages();
		bool Create();
		
		// Variables
		GETSET(bool, useEmoticons, UseEmoticons);
		
		const CAGEmotion::List& getEmoticonsList() const
		{
			return EmotionsList;
		}
		int m_CountSelEmotions; //[+]PPA
		
	protected:
		CImageList       m_images;
		CAGEmotion::List EmotionsList;
	private:
		set<string> m_FilterEmotiion;
		void cleanup();
};

#endif // AGEMOTIONSETUP_H__
